package com.elbis.action.input;

import java.util.HashMap;
import java.util.Map;

/**
 * Used for internal logging.
 * 
 * @author cc
 * 
 */
public class ErrorsHashMap {

	private static Map<Integer, String> errors = new HashMap<>();

	static {
		errors.put(ErrorMessages.SYSTEM_ERROR,
				"System error! Please contact us for further details.");
		errors.put(ErrorMessages.PERSISTENCE_MAPPING_ERROR,
				"There is no mapped value in DB for requested entity.");
		errors.put(ErrorMessages.USER_SESSION_ERROR,
				"User cannot be retrieved from session.");
		errors.put(ErrorMessages.GAME_NOT_SUPPORTED,
				"Player search requested for unsupported game.");
		errors.put(ErrorMessages.INVALID_SEARCH_INPUT_PROVIDED,
				"Wrong search input provided.");
		errors.put(ErrorMessages.ENTERED_PASSWORDS_DO_NOT_MATCH,
				"Entered password and its confirmation do not match.");
		errors.put(ErrorMessages.WRONG_EMAIL_OR_PASSWORD,
				"Provided email address or password is wrong.");
		errors.put(ErrorMessages.WRONG_ACTIVATION_VALUES,
				"Email or activation token value is not valid.");
		errors.put(ErrorMessages.ACTIVATION_LINK_EXPIRED,
				"Activation link has expired, a new one needs to be requested.");
		errors.put(ErrorMessages.ACCOUNT_ALREADY_ACTIVATED,
				"Already activated account is requested for activation.");
		errors.put(ErrorMessages.EMAIL_ADDRESS_ALREADY_DEFINED,
				"Trying to create an account with email address already in use.");
		errors.put(ErrorMessages.ENTERED_EMAILS_DO_NOT_MATCH,
				"Entered email address and confirmation values do not match.");
		errors.put(ErrorMessages.INCORRECT_CURRENT_PASSWORD,
				"Entered current password is wrong.");
		errors.put(ErrorMessages.INVALID_PASSWORD_VALUE,
				"Invalid password value entered. Either null, empty or not long enough.");
		errors.put(ErrorMessages.MANDATORY_INPUT, "Mandatory input is missing.");
		errors.put(ErrorMessages.OLD_AND_NEW_PASSWORD_SAME,
				"Current password and the newly entered one are the same.");
		errors.put(ErrorMessages.ACCOUNT_NOT_ACTIVATED,
				"Trying to login with an inactive account.");

		errors.put(ErrorMessages.WOT_API_ERROR,
				"WoT API response returned status : error");
	}

	/**
	 * Get the error message that corresponds to the given number.
	 * 
	 * @param number
	 *            error number that is defined in database to display to end
	 *            user.
	 * @return Error message to be logged, if the given error number is not
	 *         found, default message is returned.
	 */
	public static String getMessage(Integer number) {
		String message = errors.get(number);
		if (message == null) {
			message = errors.get(ErrorMessages.SYSTEM_ERROR);
		}
		return message;
	}

}
